package com.ykj.controller;


import com.ykj.dto.Result;
import com.ykj.entity.Posts;
import com.ykj.service.PostsService;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Y2014188432
 * @since 2022-05-07
 */
@RestController
@RequestMapping("/posts")
public class PostsController {

    @Resource
    private PostsService postsService;

    @GetMapping("/getPosts")
    public Result getPosts(String page,String plateId){
        return postsService.getPosts(page,plateId);
    }

    @GetMapping("/getLong")
    public Result getLong(String plateId){
        return postsService.getLong(plateId);
    }

    @GetMapping("/getPostsMessageById")
    public Result getPostsMessageById(String id){
        return postsService.getPostsMessageById(id);
    }

    @PostMapping("/changePostsState")
    public Result changePostsState(@RequestBody Posts posts){
        return postsService.changePostsState(posts);
    }

    @PostMapping("/createPosts")
    public Result createPosts(@RequestBody Posts posts){
        return postsService.createPosts(posts);
    }

    @GetMapping("/getPostsByUserId")
    public Result getPostsByUserId(String page){
        return postsService.getPostsByUserId(page);
    }
    @GetMapping("/getPostsByUserIdLong")
    public Result getPostsByUserIdLong(){
        return postsService.getPostsByUserIdLong();
    }

    @GetMapping("/deletePosts")
    public Result deletePost(String id){
        return Result.ok(postsService.removeById(id));
    }

    /**
     * 获取未审核帖子
     * @return
     */
    @GetMapping("/getNotReviewedPosts")
    public Result getNotReviewedPosts(){
        return postsService.getNotReviewedPosts();
    }
    /**
     * 获取置顶申请
     */
    @GetMapping("/getTopPostsApply")
    public Result getTopPostsApply(){
        return postsService.getTopPostsApply();
    }

    /**
     * 获取加精
     * @return
     */
    @GetMapping("/getStarPostsApply")
    public Result getStarPostsApply(){
        return postsService.getStarPostsApply();
    }

    /**
     * 获取锁定
     * @return
     */
    @GetMapping("/getLockPostsApply")
    public Result getLockPostsApply(){
        return postsService.getLockPostsApply();
    }

    /**
     * 模糊查找 Fuzzy lookup
     */
    @GetMapping("/fuzzyLookup")
    public Result fuzzyLookup(String param){
        return postsService.fuzzyLookup(param);
    }

    @GetMapping("/getPostsByStatePagePlateId")
    public Result getPostsByStatePagePlateId(String state,String page,String plateId){
        return postsService.getPostsByStatePagePlateId(state,page,plateId);
    }

}

